import { Component } from 'react'
import { View, Text, OpenData } from '@tarojs/components'
import Taro from '@tarojs/taro'
import './index.less'

export default class Index extends Component {

  componentWillMount () { }

  componentDidMount () { }

  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }

  nav = () => {
    Taro.navigateTo({
      url: '/pages/todo/todo'
    })
  }

  render () {
    let nav = () => {
      Taro.navigateTo({
        url: '/pages/todo/todo',
      });
    }
    let navToList = () => {
      Taro.navigateTo({
        url: '/pages/projectList/projectList'
      })
    }
    let canIUseOpenData = Taro.canIUse('open-data.type.userAvatarUrl') && Taro.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
    let userInfo = canIUseOpenData ? 
      <View>
        <View class="userinfo-avatar" onClick={nav}>
          <OpenData type="userAvatarUrl"></OpenData>
        </View>
        <OpenData type="userNickName"></OpenData>
      </View>
      : <View></View>

    return (
      <View className="container">
      <View className="userinfo">
        {userInfo}
      </View>
      <View className="usermotto" onClick={navToList}>
        <Text className="user-motto">Hello Remax</Text>
      </View>
    </View>
    )
  }
}
